/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ivanbiz.nilai;

import com.ivanbiz.generic.GenericDAOImpl;
import java.util.List;
import org.hibernate.Query;

/**
 *
 * @author User
 */
public class PenilaianDAOImpl extends GenericDAOImpl implements PenilaianDAO{

    public List getPenilaianByKelas(String id) throws Exception {
        Query query = getSessionFactory().getCurrentSession().createQuery("select distinct a from Penilaian a where a.accountKelas.kelas.id:=id");
        query.setString("id", id);
        return query.list();
    }

    public List getPenilaianByNama(String nama) throws Exception {
        Query query = getSessionFactory().getCurrentSession().createQuery("from Penilaian a where a.nama:=nama");
        query.setString("nama", nama);
        return query.list();
    }

    public List getPenilaianByKelasAndNilaiKriteria(String kelasId, String nilaiKriteriaId) throws Exception {
        Query query = getSessionFactory().getCurrentSession().createQuery("select distinct a from Penilaian a where a.accountKelas.kelas.id:=kelasId and a.accountKelas.nilaiKriteria.id:=nilaiKriteriaId");
        query.setString("kelasId", kelasId);
        query.setString("nilaiKriteriaId", nilaiKriteriaId);
        return query.list();
    }

}
